package com.singerw.controller;

import com.alibaba.fastjson.JSONObject;
import com.singerw.annotations.ResponseResult;
import com.singerw.service.LogService;
import com.singerw.service.TwTeamService;
import com.singerw.service.TwUserService;
import com.singerw.service.oss.OSSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version V1.0
 * @Package com.singerw.controller
 * @auhter 张欣
 * @date 2021/1/24-2:18 PM
 */

@RestController
@RequestMapping("/console")
public class ConsoleController {

    @Autowired
    private OSSService ossService;
    @Autowired
    private TwUserService twUserService;
    @Autowired
    private TwTeamService twTeamService;
    @Autowired
    private LogService logService;
    @GetMapping("/statistics")
    @ResponseResult
    public JSONObject Statistics(){
        JSONObject resultObject = new JSONObject();
        resultObject.put("userSpaceInfo",ossService.getSpaceInfo("user_space/"));
        resultObject.put("userTeamSpaceInfo",ossService.getSpaceInfo("user_team/"));
        resultObject.put("userNumber",twUserService.list().size());
        resultObject.put("teamNumber",twTeamService.TeamList().size());

        return resultObject;
    }

    @GetMapping("/log/list")
    @ResponseResult
    public String logList(){
        return logService.LogList();
    }
    @GetMapping("/log/login/list")
    @ResponseResult
    public String loginLogList(){
        return logService.LoginList();
    }


}
